import time
from selenium.webdriver.common.by import By
from yuekao.Page.Page import Page
class Page1(Page):
    # 断言2：判断是否登录成功
    dy2_loc=(By.XPATH,'//*[@id="s-top-username"]/span[2]')
    # 点击搜索框输入：北京时间
    search_loc=(By.ID,'chat-textarea')
    # 点击搜索
    searchbtn_loc=(By.ID,'chat-submit-button')
    # 滚动到底部
    # 点击第三页
    three_loc=(By.CSS_SELECTOR,'.page-item_M4MDr pc')
    #查看内容详情
    about_loc=(By.XPATH,'//*[@id="21"]/div/div/div/div[1]/div/h3/a/div/div/p/span/span/span/em')
    #点击首页
    back_loc=(By.XPATH,'//*[@id="mainmenu"]/ul/li[1]/a')
    # # 断言2：判断是否登录成功
    def dy2(self):
        return self.text(self.dy2_loc)
    # 搜索框输入内容
    def search(self):
        self.send_keys(self.search_loc,'北京时间')
    # 点击搜索按钮
    def searchbtn(self):
        self.click(self.searchbtn_loc)
    # 选择第三页
    def three(self):
        self.click(self.three_loc)
    # 选择相关内容
    def about(self):
        self.click(self.about_loc)
    # 点击进入首页
    def back(self):
        self.click(self.back_loc)

    def baidu_luoji2(self):
        self.baidu_luoji_login()
        # 断言是否登录成功
        print(self.dy2())
        assert 'ZangXuRui' == self.dy2()
        self.search()
        self.searchbtn()
        time.sleep(5)
        self.scrollHeight()
        time.sleep(2)
        # self.three()
        # self.about()






